package addon.w3.mdx.com;

import java.io.IOException;

import addon.w3.mdx.MDXCOM;
import addon.w3.mdx.LEDataInputStream;
import addon.w3.mdx.MDXException;

public class MDXMatriceCOM extends MDXCOM {
	int lengthOfEachGroup[];
	int length;
	public int matrices[][];
	
	public MDXMatriceCOM(int length[]) {
		lengthOfEachGroup = length;
	}
	
	public String getTag() {
		return "MATS";
	}
	
	public void _decode(LEDataInputStream ins) throws IOException, MDXException {
		length = ins.readInt();
//		matrices = new int[length];
//		for (int i = 0; i < matrices.length; i++) {
//			matrices[i] = ins.readInt();
//		}
		
		matrices = new int[lengthOfEachGroup.length][];
		
		for(int i=0; i<lengthOfEachGroup.length; i++) {
			matrices[i] = new int[ lengthOfEachGroup[i] ];
			for(int m=0;m<matrices[i].length;m++) {
				matrices[i][m] = ins.readInt();
			}
		}
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("TAG : "+getTag());
		if(matrices != null && matrices.length > 0) sb.append("\n\tMATRICES[] : "+matrices.length);
		return sb.toString();
	}

	@Override
	public boolean isImplicitTag() {
		// TODO Auto-generated method stub
		return true;
	}
}
